package com.wlyuan.open.scanner.constant;

import com.wlyuan.core.marker.NamedValue;
import com.wlyuan.core.marker.NamedValueMap;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Map;

/**
 * @author lijing
 * @description
 */
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
@Getter
public enum AddressTypeEnum implements NamedValue<Integer> {

    //收货
    RECEIVINGADDRESS(1, "收货方地址"),
    //客户-发货方
    CUSTOMER(2, "发货方地址"),
    //线上承运方
    ONLINE_CARRIER(3, "线上承运方站点地址"),
    //线下承运方
    OFFLINE_CARRIER(4, "线下承运方站点地址"),
    ;

    private final Integer value;
    private final String name;

    private static final Map<Integer, AddressTypeEnum> MAP = new NamedValueMap<>(AddressTypeEnum.class);

    public static AddressTypeEnum fromValue(Integer value) {
        return MAP.get(value);
    }

    public static boolean isCustomer(Integer val) {
        return CUSTOMER.value.equals(val);
    }

    public static boolean isReceiving(Integer val) {
        return RECEIVINGADDRESS.value.equals(val);
    }

    public static boolean isOnline(Integer val) {
        return ONLINE_CARRIER.value.equals(val);
    }

    public static boolean isOffline(Integer val) {
        return OFFLINE_CARRIER.value.equals(val);
    }

}
